package code.rocky.sync;

import java.util.concurrent.TimeUnit;

public class SyncTest3 {

    private static int INIT_VALUE = 0;
    private static int TOTAL      = 10;

    static class count implements Runnable{
        @Override
        public void run() {
            while (true) {
                if (INIT_VALUE > TOTAL) {
                    break;
                }
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + " INIT_VALUE: " + (INIT_VALUE++));
            }
        }
    }

    public static void main(String[] args) {

        new Thread(new SyncTest3.count(),"t1").start();
        new Thread(new SyncTest3.count(),"t2").start();
        new Thread(new SyncTest3.count(),"t3").start();

    }


}


